package com.dandelion.common.domain;

public enum OrderStatusEnum {
    UNKNOWN("未知状态", -1),
    PROCESSING("进行中", 0),
    FINISHED("已完成", 1),
    CANCELLED("已取消", 2);

    private String statusName;
    private int value;

    public static final OrderStatusEnum of(Byte value) {
        if (value == null) {
            return UNKNOWN;
        }
        for (OrderStatusEnum status : values()) {
            if (status.getValue() == value) {
                return status;
            }
        }
        return UNKNOWN;
    }

    OrderStatusEnum(String statusName, int value) {
        this.statusName = statusName;
        this.value = value;
    }

    public String getStatusName() {
        return statusName;
    }

    public int getValue() {
        return value;
    }

    public byte getByteValue() {
        return (byte) value;
    }
}
